#coding=utf-8
import os
import os.path
import xml.dom.minidom
from os import getcwd

wd = getcwd()
path2 = ('%s/Annotations'%(wd))
files = os.listdir(path2)

for xmlFile in files:
    xmlPath = os.path.join(path2,xmlFile)
    try:
        dom=xml.dom.minidom.parse(xmlPath)
        root=dom.documentElement

        names=root.getElementsByTagName('name')
        for name in names:
            if name.firstChild.data =="men":
                print(name.firstChild.data,"==>")
                name.firstChild.data="body"
                print(name.firstChild.data)
    except:
        print(xmlPath)
        continue
    with open(os.path.join(path2,xmlFile),'w') as fh:
            dom.writexml(fh)
            print('写入name OK!')
